<!doctype html>
<html>
<body>
    <div>
        <h3>result:</h3>
        <textarea id="result" rows="50" cols="100"></textarea>
    </div>

    <script src="../../../flycv.js" type="text/javascript"></script>
    <script type="text/javascript">
        let resultHtml = document.getElementById("result");

        fcv.then((fcv) => {
            // mock数据
            let srcGray = new fcv.Mat(300, 200, fcv.FCVImageType.GRAY_U8);
            let mockData = [];

            for (let i = 0; i < 300 * 200; i++) {
                mockData.push(i % 256);
            }

            srcGray.data().set(mockData);

            // 调用
            let dst = new fcv.Mat();
            fcv.connectedComponents(srcGray, dst, 8, fcv.FCVImageType.GRAY_S32);

            // 可视化
            resultHtml.append(dst.data());

            // 内存回收
            srcGray.delete();
            dst.delete();
        });
    </script>
</body>
</html>